package com.keshe.dao;

import com.keshe.domain.User;
import com.keshe.util.DBUtil;

import java.util.List;

public class UserDao {
    //添加账号至数据库
    public int insertUSer(User user){
        String sql="insert user values(?,?)";
        int count= DBUtil.update(sql,user.getId(),user.getPassword());//返回影响数据数目
        return count;
    }
    //查询
    public List<User> selectId(String id){
        String sql = "select * from user where id=?";
        List<User> list=DBUtil.query(sql,User.class,id);
        return list;
    }
    //修改密码
    public int updateUser(String id,String passworld){
        String sql="update user set password=? where id=?";
        int count= DBUtil.update(sql,passworld,id);
        return count;
    }

    public static void main(String[] args) {
        UserDao userDao = new UserDao();
        List<User> admin = userDao.selectId("admin");
        System.out.println(admin);
    }
}
